/*
 * @Descripttion: 核酸宝项目前端
 * @version: 
 * @Author: 杜宇轩
 * @Date: 2022-05-22 05:23:33
 * @LastEditors: 杜宇轩
 * @LastEditTime: 2022-05-22 06:18:29
 */
const commonUser = {
  namespaced: true,
  state: {
    token: {
      token: '',
      lastTime: 0
    },
    username: '',
    type: '', // CONSUMER VOLUNTEER APPROVAL DOCTOR MANAGER
    userId: '',
    currentNotice: {},
    currentApply: {}
  },

  getters: {
    getUsername: (state) => {
      return state.username;
    },
    getType: (state) => {
      return state.type;
    },
    getCurrentNotice: (state) => {
      return state.currentNotice;
    },
    getCurrentApply: (state) => {
      return state.currentApply;
    }
  },

  mutations: {
    SET_DATA: (state, payload) => { // 从localStorage同步
      state.type = payload.type;
      state.username = payload.username;
      state.token = payload.token;
      state.userId = payload.userId;
      state.currentNotice = payload.currentNotice;
      state.currentApply = payload.currentApply;
    },
    setNotice: (state, payload) => {
      state.currentNotice = payload;
    },
    setApply: (state, payload) => {
      state.currentApply = payload;
    },
    clearData: (state) => {
      state.type = '';
      state.username = '';
      state.token = {};
    }
  },

  actions: {
  }

};

export default commonUser;
